package com.eh.erd.core.controller.admin;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.eh.common.result.R;
import com.eh.erd.core.pojo.entity.UserInfo;
import com.eh.erd.core.pojo.query.UserInfoQuery;
import com.eh.erd.core.service.UserInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author zhuyuanwei
 * @version 1.0
 * @date 2021/5/20 16:23
 */
@Api(tags = "会员管理")
@RestController
@RequestMapping("/admin/core/userInfo")
public class AdminUserInfoController {

    @Autowired
    private UserInfoService userInfoService;

    @ApiOperation("获取会员列表")
    @GetMapping("/list/{page}/{limit}")
    public R listPage(@ApiParam("当前页") @PathVariable Long page,
                      @ApiParam("每页记录数") @PathVariable Long limit,
                      @ApiParam("查询条件对象") UserInfoQuery userInfoQuery
                      ){
       IPage<UserInfo> UserInfoPage = userInfoService.getUserInfoListByPage(page,limit,userInfoQuery);

       return R.ok().message("查询成功").data("pageModel",UserInfoPage);
    }


    @ApiOperation("解锁和锁定")
    @PutMapping("/lock/{id}/{status}")
    public R lock(@PathVariable @ApiParam(value = "解锁和锁定id",required = true) Long id,
                  @PathVariable @ApiParam(value = "解锁和锁定(0=锁定，1=解锁)",required = true) Integer status
    ){

        userInfoService.lock(id,status);
        return R.ok().message(status==1?"解锁成功":"锁定成功");
    }



}
